package com.ymdx.service.impl;

import com.ymdx.dao.impl.BaseDaoImpl;
import com.ymdx.entity.News;
import com.ymdx.service.NewsService;
import com.ymdx.util.Page;
import com.ymdx.util.tool.HqlUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by yangliwei on 2017/8/14.
 */
@Service("newsService")
@Transactional
public class NewsServiceImpl extends BaseServiceImpl<News, Long> implements NewsService {
    @Resource
    BaseDaoImpl newsDao;

    @Override
    public Page<News> page(Page<News> page, Map<String, Object> args) {
        StringBuilder hql = new StringBuilder("from News where valid = true ");
        List params = new ArrayList();

        HqlUtil.andHql(hql,args,params);
        return newsDao.page(hql.toString(), page, params.toArray());
    }
}
